package fun.chutianshu.competitionmanagement.daomapper;

import fun.chutianshu.competitionmanagement.pojo.Student;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface StudentMapper {
      /***
        * 查询数据表中的所有记录
     * 对应SQL：select * from Student
     * @return
       * */
    @Select("SELECT * FROM student")
    List<fun.chutianshu.competitionmanagement.pojo.Student> getAllStudent();

    /***
     * 查询数据表中的某一条记录

     * @return
     */
    @Select("SELECT * FROM student where stu_code = #{stuCode}")
    Student getStudent(@Param("stuCode") int stuCode);

    /***
     * 插入一条数据
     * @return
     */
    @Insert("INSERT INTO student(stu_name,stu_gender,phone_num,birthday,photo,weixin_num,class_id,isatschool) VALUES(#{stuName},#{stuGender},#{phoneNum},#{birthday},#{photo},#{weixinNum},#{classId},#{isatschool})")
    int insertStudent(Student student);


    /***
     * 更新一条记录（@UpdateProvider）
     * @param Student 准备更新进去的数据
     * @return
     */
    @UpdateProvider(type = fun.chutianshu.competitionmanagement.daomapper.SqlProvider.class, method = "updateStudentSql")
    int updateStudent(Student Student);

    /***
     * 删除某条记录（@Delete）

     * @return
     */
    @Delete("DELETE FROM student WHERE stu_code = #{stuCode}")
    int deleteStudent(@Param("stuCode") int stuCode);
}
